- 
          
- 
                Notifications
    You must be signed in to change notification settings 
- Fork 584
chore!: use testcontainers.Run function everywhere #3174
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
          
     Draft
      
      
            mdelapenya
  wants to merge
  104
  commits into
  testcontainers:main
  
    
      
        
          
  
    
      Choose a base branch
      
     
    
      
        
      
      
        
          
          
        
        
          
            
              
              
              
  
           
        
        
          
            
              
              
           
        
       
     
  
        
          
            
          
            
          
        
       
    
      
from
mdelapenya:use-run-function
  
      
      
   
  
    
  
  
  
 
  
      
    base: main
Could not load branches
            
              
  
    Branch not found: {{ refName }}
  
            
                
      Loading
              
            Could not load tags
            
            
              Nothing to show
            
              
  
            
                
      Loading
              
            Are you sure you want to change the base?
            Some commits from the old base branch may be removed from the timeline,
            and old review comments may become outdated.
          
          
      
        
          +3,990
        
        
          −4,729
        
        
          
        
      
    
  
Conversation
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
    
  This was referenced Oct 7, 2025 
      
    
  mdelapenya 
      added a commit
        to mdelapenya/testcontainers-go
      that referenced
      this pull request
    
      Oct 9, 2025 
    
    
      
  
    
      
    
  
This commit migrates the valkey module to use the new testcontainers.Run() API. The main changes are: - Use testcontainers.Run() instead of testcontainers.GenericContainer() - Use entrypoint for valkey-server process and WithCmd/WithCmdArgs for arguments - Simplify WithConfigFile to prepend config file as first argument - Simplify WithLogLevel and WithSnapshotting to use WithCmdArgs directly - Process custom options before building module options for TLS support - Update option tests to reflect entrypoint-based approach Ref: testcontainers#3174 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <[email protected]>
  This was referenced Oct 9, 2025 
      
    
  mdelapenya 
      added a commit
        to mdelapenya/testcontainers-go
      that referenced
      this pull request
    
      Oct 9, 2025 
    
    
      
  
    
      
    
  
This commit migrates the vearch module to use the new testcontainers.Run() API. The main changes are: - Use testcontainers.Run() instead of testcontainers.GenericContainer() - Convert to moduleOpts pattern with functional options - Use WithExposedPorts, WithCmd, WithHostConfigModifier, WithFiles, WithWaitStrategy Ref: testcontainers#3174 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <[email protected]>
    
  mdelapenya 
      added a commit
        to mdelapenya/testcontainers-go
      that referenced
      this pull request
    
      Oct 9, 2025 
    
    
      
  
    
      
    
  
This commit migrates the weaviate module to use the new testcontainers.Run() API. The main changes are: - Use testcontainers.Run() instead of testcontainers.GenericContainer() - Convert to moduleOpts pattern with functional options - Use WithCmd, WithExposedPorts, WithEnv, WithWaitStrategy - Multiple wait strategies for HTTP and gRPC ports Tests: 7 tests, 78.6% coverage Ref: testcontainers#3174 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <[email protected]>
    
  mdelapenya 
      added a commit
      that referenced
      this pull request
    
      Oct 9, 2025 
    
    
      
  
    
      
    
  
This commit migrates the vearch module to use the new testcontainers.Run() API. The main changes are: - Use testcontainers.Run() instead of testcontainers.GenericContainer() - Convert to moduleOpts pattern with functional options - Use WithExposedPorts, WithCmd, WithHostConfigModifier, WithFiles, WithWaitStrategy Ref: #3174 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-authored-by: Claude <[email protected]>
    
  mdelapenya 
      added a commit
        to mdelapenya/testcontainers-go
      that referenced
      this pull request
    
      Oct 9, 2025 
    
    
      
  
    
      
    
  
This commit migrates the vault module to use the new testcontainers.Run() API. The main changes are: - Use testcontainers.Run() instead of testcontainers.GenericContainer() - Convert to moduleOpts pattern with functional options - Use WithExposedPorts, WithHostConfigModifier, WithWaitStrategy, WithEnv - WithToken uses WithEnv for setting root token env vars - WithInitCommand uses WithAdditionalWaitStrategy to append exec wait Tests: 10 tests, 89.5% coverage Ref: testcontainers#3174 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <[email protected]>
    
  mdelapenya 
      added a commit
        to mdelapenya/testcontainers-go
      that referenced
      this pull request
    
      Oct 9, 2025 
    
    
      
  
    
      
    
  
This commit migrates the yugabytedb module to use the new testcontainers.Run() API. The main changes are: - Use testcontainers.Run() instead of testcontainers.GenericContainer() - Convert to moduleOpts pattern with functional options - Use WithCmd, WithWaitStrategy, WithExposedPorts, WithEnv - Use Inspect after Run to retrieve actual env var values after user customizations - Multiple wait strategies for logs and listening ports Tests: 9 tests, 93.0% coverage Ref: testcontainers#3174 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <[email protected]>
    
  mdelapenya 
      added a commit
      that referenced
      this pull request
    
      Oct 9, 2025 
    
    
      
  
    
      
    
  
This commit migrates the weaviate module to use the new testcontainers.Run() API. The main changes are: - Use testcontainers.Run() instead of testcontainers.GenericContainer() - Convert to moduleOpts pattern with functional options - Use WithCmd, WithExposedPorts, WithEnv, WithWaitStrategy - Multiple wait strategies for HTTP and gRPC ports Tests: 7 tests, 78.6% coverage Ref: #3174 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-authored-by: Claude <[email protected]>
    
  mdelapenya 
      added a commit
      that referenced
      this pull request
    
      Oct 9, 2025 
    
    
      
  
    
      
    
  
This commit migrates the yugabytedb module to use the new testcontainers.Run() API. The main changes are: - Use testcontainers.Run() instead of testcontainers.GenericContainer() - Convert to moduleOpts pattern with functional options - Use WithCmd, WithWaitStrategy, WithExposedPorts, WithEnv - Use Inspect after Run to retrieve actual env var values after user customizations - Multiple wait strategies for logs and listening ports Tests: 9 tests, 93.0% coverage Ref: #3174 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-authored-by: Claude <[email protected]>
    
  mdelapenya 
      added a commit
      that referenced
      this pull request
    
      Oct 9, 2025 
    
    
      
  
    
      
    
  
* chore(valkey): use Run function 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <[email protected]> * chore(valkey): use Run function This commit migrates the valkey module to use the new testcontainers.Run() API. The main changes are: - Use testcontainers.Run() instead of testcontainers.GenericContainer() - Use entrypoint for valkey-server process and WithCmd/WithCmdArgs for arguments - Simplify WithConfigFile to prepend config file as first argument - Simplify WithLogLevel and WithSnapshotting to use WithCmdArgs directly - Process custom options before building module options for TLS support - Update option tests to reflect entrypoint-based approach Ref: #3174 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <[email protected]> * chore: reduce file permissions --------- Co-authored-by: Claude <[email protected]>
    
  mdelapenya 
      added a commit
      that referenced
      this pull request
    
      Oct 9, 2025 
    
    
      
  
    
      
    
  
This commit migrates the vault module to use the new testcontainers.Run() API. The main changes are: - Use testcontainers.Run() instead of testcontainers.GenericContainer() - Convert to moduleOpts pattern with functional options - Use WithExposedPorts, WithHostConfigModifier, WithWaitStrategy, WithEnv - WithToken uses WithEnv for setting root token env vars - WithInitCommand uses WithAdditionalWaitStrategy to append exec wait Tests: 10 tests, 89.5% coverage Ref: #3174 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-authored-by: Claude <[email protected]>
  
    Sign up for free
    to join this conversation on GitHub.
    Already have an account?
    Sign in to comment
  
      
  Add this suggestion to a batch that can be applied as a single commit.
  This suggestion is invalid because no changes were made to the code.
  Suggestions cannot be applied while the pull request is closed.
  Suggestions cannot be applied while viewing a subset of changes.
  Only one suggestion per line can be applied in a batch.
  Add this suggestion to a batch that can be applied as a single commit.
  Applying suggestions on deleted lines is not supported.
  You must change the existing code in this line in order to create a valid suggestion.
  Outdated suggestions cannot be applied.
  This suggestion has been applied or marked resolved.
  Suggestions cannot be applied from pending reviews.
  Suggestions cannot be applied on multi-line comments.
  Suggestions cannot be applied while the pull request is queued to merge.
  Suggestion cannot be applied right now. Please check back later.
  
    
  
    
What does this PR do?
It applies the recently added
testcontainers.Runfunction in the core and in all the modules, deprecating the usage of theGenericContainerexposed function.For that, we needed to review all the modules, and:
moduleOptionsrepresenting the values in the original container requestmoduleOptssliceoptionsstruct, and a customOptiontype representing the module's own customisation types. If that struct and the Option type existed, we added a map[string]string for the env vars, changing all the existing options that could set env vars into the container request, into an Option type writing the passed-in values to the newenvfield in the options. Why? Because with this new approach, the module has no access to the container request within the scope of the Run method, so we need to change the functional opts and read those env vars from the options instead. The module's Run function now has to loop through the passed-in options and apply its own options.testcontainers.WithEnv), as they are processed internally in thetestcontainers.Runfunction.moduleOptions.The result is that the
testcontainers.Runfunction receives a slice of core options.This is considered a breaking change, as for those modules where we changed the existing options to the new custom type, the function signature changed. In practice, users that simply passed the options to the Run function has nothing to change, but we acknowledge that there could be users that are assigning these options to a variable, and here they will receive the breaking change. This could happen mostly in tests and test tables.
Apart from this, we noticed that several modules had their internal
Optiontype not returning errors, which was not consistent for our pattern to validate the options. Given this PR is already a BC for many modules, we took the chance to update those modules' options to return error, causing another breaking change.The first commit in this PR is deprecating the
GenericContainerfunction, so consumer would need to update to theRunfunction whenever possible. Their lint process should warn them at build/CI time.Modules that receive a Breaking Change
Why is it important?
testcontainers.GenericContainerhas been an important function in the library since the beginning, but we consider that havingtestcontainers.Runis much more idiomatic to the operations we want to do, which is no other than running a container. Also, it pairs with thedocker runcommand.With the addition of functional options for all the container request fields, we consider it's now possible to even deprecate the struct, move it to an internal package in the library, and always customise containers through the functional options APIs.